var e = require("../@babel/runtime/helpers/regeneratorRuntime"), r = require("../@babel/runtime/helpers/asyncToGenerator"), t = require("../@babel/runtime/helpers/objectSpread2"), n = require("../common/vendor.js"), s = require("../utils/luch-request/core/Request.js"), o = require("../uni_modules/u-store/js_sdk/Storage.js"), u = require("../config/config.js"), i = new s.Request();

i.setConfig(function(e) {
    return e.baseURL = u.base.apiUrl, e.header = t(t({}, e.header), {}, {
        userId: o.Storage.get("userd"),
        storeId: u.base.storeId
    }), e;
}), i.interceptors.request.use(function(e) {
    return e.header = t(t({}, e.header), {}, {
        Authorization: "bearer  " + o.Storage.get("token")
    }), e;
}, function(e) {
    return Promise.reject(e);
}), i.interceptors.response.use(function() {
    var t = r(e().mark(function r(t) {
        return e().wrap(function(e) {
            for (;;) switch (e.prev = e.next) {
              case 0:
                return e.abrupt("return", (-1 == t.data.code && n.index.showModal({
                    title: "请登录",
                    content: "登录失效或者未登录",
                    showCancel: !1,
                    success: function(e) {
                        n.index.redirectTo({
                            url: "/pages/ucenter/login/login"
                        });
                    }
                }), t));

              case 1:
              case "end":
                return e.stop();
            }
        }, r);
    }));
    return function(e) {
        return t.apply(this, arguments);
    };
}(), function(e) {
    return void 0 !== e.statusCode ? (n.index.showModal({
        title: "错误码：" + e.statusCode,
        content: "哎呀，系统出问题了！",
        showCancel: !1,
        success: function(r) {
            var t = {
                statusCode: e.statusCode
            };
            n.index.redirectTo({
                url: "/pages/ucenter/feedback/feedback?params=" + encodeURIComponent(JSON.stringify(t))
            });
        }
    }), !1) : (n.index.showToast({
        icon: "error",
        title: "网络连接错误！"
    }), Promise.reject(e));
}), exports.http = i;